# Maintainer: Konstantin Podsvirov <konstantin@podsvirov.pro>

_realname=pyscroll
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.29
pkgrel=2
pkgdesc="Make scrolling games with animated maps in pygame (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/bitcraft/pyscroll"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-pygame")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-pytmx: Support for pytmx loaded maps from Tiled Map Editor")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
source=("${_realname}-$pkgver.tar.gz::${url}/archive/v${pkgver}.tar.gz")
sha256sums=('21ef22c2261e48aa4ac976fff899a2cfc244fa948ffec4cb910a2c89e3b171ea')

prepare() {
  rm -rf "python-build-${MSYSTEM}" | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m unittest tests/pyscroll/test_pyscroll.py test || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 license.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/license.txt"
}
